package com.bidepan.特殊类型注入;
import java.util.List;
import java.util.Map;

public class Student {
    //一个学生有多个老师
    private Map<Lesson, Teacher> teacherMap;
    public Map<Lesson, Teacher> getTeacherMap() {
        return teacherMap;
    }

    public List<Lesson> getLessonList() {
        return lessonList;
    }

    public void setLessonList(List<Lesson> lessonList) {
        this.lessonList = lessonList;
    }

    //一个学生多门课
    private List<Lesson> lessonList;

    public void setTeacherMap(Map<Lesson, Teacher> teacherMap) {
        this.teacherMap = teacherMap;
    }

    private String Sid;
    private String Sname;

    public void run(){
        System.out.println("学号: " + Sid + " 姓名: " + Sname);
        try{
            System.out.println("老师有：");
            for(Map.Entry<Lesson,Teacher> entry: teacherMap.entrySet()){
                System.out.println(entry.getKey().toString()+"|"+entry.getValue().toString());
            }
        }catch(Exception e){
            System.out.println("该bean暂未注入teacher依赖");
        }

        try{
            System.out.println("课程有：");
            for(Lesson lesson: lessonList){
                System.out.print(lesson.getLname()+' ');
            }
        }catch (Exception e){
            System.out.println("该bean暂未注入lesson依赖");
        }
    }
    public void setSid(String sid) {
        Sid = sid;
    }
    public void setSname(String sname) {
        Sname = sname;
    }
    public String getSid() {
        return Sid;
    }
    public String getSname() {
        return Sname;
    }
    @Override
    public String toString() {
        return "Student{" +
                "Sid='" + Sid + '\'' +
                ", Sname='" + Sname + '\'' +
                '}';
    }
}
